<!--
 * @Author: wu07 1732042133@qq.com
 * @Date: 2023-01-14 15:25:58
 * @LastEditors: wu07 1732042133@qq.com
 * @LastEditTime: 2023-02-02 10:14:45
 * @FilePath: \recruitAPP\recruitApp\recruitApp\src\pages\login\Verify.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!-- 视图层 -->
<template>
  <van-nav-bar
    title="验证"
    left-text="返回"
    left-arrow
    @click-left="onClickLeft"
  />
  <van-tabs v-model:active="active" title-active-color="#0079FE" color="#fff">
    <van-tab title="1.验证手机号码">
      <van-form @submit="onSubmit">
        <van-cell-group inset>
          <van-field
            v-model="username"
            left-icon="phone-o"
            name="username"
            placeholder="请输入注册手机号码"
            :rules="[{ required: true, message: '请填写手机号码' }]"
          />
          <van-field
            v-model="password"
            center
            left-icon="sign"
            name="password"
            placeholder="请输入验证码"
            :rules="[{ required: true, message: '请填写验证码' }]"
          >
            <template #button>
              <van-button size="small" type="primary">发送验证码</van-button>
            </template>
          </van-field>
        </van-cell-group>
        <div style="margin: 16px">
          <van-button round block type="primary" native-type="submit">
            下一步
          </van-button>
        </div>
      </van-form>
    </van-tab>
    <van-tab title="2.设置新密码" disabled></van-tab>
  </van-tabs>
</template>
<!-- 逻辑层 -->
<script setup>
import { get, post, put, del } from "~/axios/http";
import { showDialog } from "vant";
import { ref } from "vue";
// 导入useRouter方法
import { useRouter } from "vue-router";
const router = useRouter();
// 返回上一页
const onClickLeft = () => {
  router.go(-1);
};
// 表单
const username = ref("");
const password = ref("");
async function onSubmit(values) {
  let res = await get("/api/infomation");
  res.data.forEach((element) => {
    if (element.iphone == values.username) {
      router.push({
        path: "/revise",
        query: {
          id: element.id,
        },
      });
      throw new Error();
    } else {
      showDialog({
        title: "提示",
        message: "手机号码错误",
      });
      username.value = "";
      password.value = "";
    }
  });
}
</script>
<!-- 样式层 -->
<style  scoped>
</style>